package com.mapper;

import com.entity.History;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface HistoryMapper {

    @Insert("insert into history (userid,commid,views,recent)" +
            "value (#{userid},#{commid},#{views},#{recent})")
    int insertHistory(History history);

    @Select("select * from history")
    List<History> selectAllHistory();

    @Select("select * from history where userid = #{userid}")
    List<History> selectHistoryByUid(String userid);

    @Select("select * from history where userid = #{userid} and commid=#{commid}")
    History selectHistoryByUidAndCid(@Param("userid")String userid, @Param("commid")String commid);

    @Update("UPDATE history SET views=#{views}, recent=#{recent} WHERE userid=#{userid} AND commid=#{commid}")
    int updateHistory(History history);

}
